package com.olympus.hermes.order.domain;

import com.olympus.hermes.common.support.AbstractEntity;
import com.olympus.hermes.order.constants.OrderStatus;
import com.olympus.hermes.order.constants.PayType;
import com.olympus.hermes.order.constants.SourceType;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.time.Instant;

/**
 * @author Mickey
 * @since 2021/2/19
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@Table(name = "hermes_member")
public class Order extends AbstractEntity {

    @Column(columnDefinition = "bigint(20) DEFAULT NULL COMMENT '用户id'")
    private Long memberId;

    @Column(columnDefinition = "bigint(20) DEFAULT NULL COMMENT '订单号'")
    private Long orderSn;

    @Column(columnDefinition = "bigint(20) DEFAULT NULL COMMENT '订单总额'")
    private BigDecimal totalAmount;

    @Column(columnDefinition = "bigint(20) DEFAULT NULL COMMENT '应付总额'")
    private BigDecimal payAmount;

    @Column(columnDefinition = "bigint(20) DEFAULT NULL COMMENT '运费金额'")
    private BigDecimal freightAmount;

    @Column(columnDefinition = "bigint(20) DEFAULT NULL COMMENT '促销优化金额'")
    private BigDecimal promotionAmount;

    @Convert(converter = PayType.Converter.class)
    @Column(columnDefinition = "int(10) DEFAULT NULL COMMENT '支付方式'")
    private PayType payType;

    @Convert(converter = SourceType.Converter.class)
    @Column(columnDefinition = "int(10) DEFAULT NULL COMMENT '订单来源'")
    private SourceType sourceType;

    @Convert(converter = OrderStatus.Converter.class)
    @Column(columnDefinition = "int(10) DEFAULT NULL COMMENT '订单状态'")
    private OrderStatus status;

    /**
     * 物流公司(配送方式)
     */
    private String deliveryCompany;

    /**
     * 物流单号
     */
    private String deliverySn;

    /**
     * 收货人姓名
     */
    private String receiverName;

    /**
     * 收货人电话
     */
    private String receiverPhone;

    /**
     * 收货人邮编
     */
    private String receiverPostCode;

    /**
     * 省份/直辖市
     */
    private String receiverProvince;

    /**
     * 城市
     */
    private String receiverCity;

    /**
     * 区
     */
    private String receiverRegion;

    /**
     * 详细地址
     */
    private String receiverDetailAddress;

    /**
     * 订单备注
     */
    private String note;

    /**
     * 支付时间
     */
    private Instant paymentTime;

}
